package com.tarena.lbs.stock.web.converter;

import com.tarena.lbs.base.protocol.pager.BasePageList;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.pojo.stock.bo.CouponStockBO;
import com.tarena.lbs.pojo.stock.dos.CouponStockDO;
import com.tarena.lbs.pojo.stock.vo.CouponStockVO;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CouponStockConverter {

    public PageResult<CouponStockVO> assemblePageVOS(BasePageList<CouponStockBO> bos) {
        PageResult<CouponStockVO> result = new PageResult<>();
        List<CouponStockVO> vos = new ArrayList<>();
        BeanUtils.copyProperties(bos,vos);
        result.setTotal(bos.getTotal());
        result.setObjects(vos);
        return result;
    }

    public CouponStockVO bo2vo(CouponStockBO bo) {
        if (bo == null) {
            return null;
        }
        CouponStockVO vo = new CouponStockVO();
        BeanUtils.copyProperties(bo,vo);
        return vo;
    }

    public CouponStockBO do2bo(CouponStockDO tempDo) {
        if (tempDo == null) {
            return null;
        }
        CouponStockBO bo = new CouponStockBO();
        BeanUtils.copyProperties(tempDo,bo);
        return bo;
    }
}
